/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controle.gui.utils;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JTextField;

/**
 *
 * @author Maycon Fernando Silva Brito
 * @email mayconfsbrito@gmail.com
 */
public class ApagaElementosDaInterface {

    public void apagaJTextField(JTextField... args) {
        apagaJTextField(true, args);


    }

    public void apagaJTextField(boolean apagaPreenchidos, JTextField... args) {
        for (int i = 0; i < args.length; i++) {
            if (args[i] != null) {
                if ((!apagaPreenchidos && args[i].getText().isEmpty())
                || apagaPreenchidos){
                    args[i].setText("");
                }
            }
        }
    }

    public void apagaJComboBox(JComboBox... args) {

        for (int i = 0; i < args.length; i++) {
            if (args[i] != null) {
                args[i].setSelectedIndex(0);
            }
        }

    }

    public void apagaModelJComboBox(JComboBox... args) {

        for (int i = 0; i < args.length; i++) {
            if (args[i] != null) {
                args[i].setModel(new DefaultComboBoxModel(new String[]{"Selecione..."}));

            }
        }

    }

    public void apagaCheckBox(JCheckBox... args) {

        for (int i = 0; i < args.length; i++) {
            if (args[i] != null) {
                args[i].setSelected(false);
            }
        }
    }
}
